
#include "Vehicle.h"
#include "../ScriptApi.h"

namespace GTA
{

#pragma region Constructor
	Vehicle::Vehicle()
	{
	}

	Vehicle::Vehicle(u32 handle)
	{
		Handle = handle;
	}
	
	Vehicle::Vehicle(Scripting::Vehicle veh)
	{
		Base = veh;
	}
#pragma endregion

#pragma region Base
	// Propert Base
	Scripting::Vehicle Vehicle::Base::get()
	{ // all it does is return a new Scripting::Vehicle with our handle, so remember not to use this as a pointer
		Scripting::Vehicle veh;
		veh.Handle = Handle;
		return veh;
	}
	void Vehicle::Base::set(Scripting::Vehicle veh)
	{
		Handle = veh.Handle;
	}
	// --------------

	bool Vehicle::Exists()
	{
		return Scripting::DoesVehicleExist(this->Base);
	}
	bool Vehicle::Exists(Vehicle^ veh)
	{ // STATIC!
		if (veh == nullptr) return false;
		if (veh->Handle == 0) return false;
		return veh->Exists();
	}
#pragma endregion Base, Exists()

#pragma region Properties
	// Property Coordinates
	GTA::Vector3^ Vehicle::Coordinates::get()
	{
		float x,y,z;
		pin_ptr<float> pX = &x;
		pin_ptr<float> pY = &y;
		pin_ptr<float> pZ = &z;
		Scripting::Vehicle veh;
		Scripting::GetCarCoordinates(Base,pX,pY,pZ);
		GTA::Vector3^ pos = gcnew GTA::Vector3(x,y,z);
		return pos;
	}
	void Vehicle::Coordinates::set(GTA::Vector3^ pos)
	{
		Scripting::SetCarCoordinates(Base,pos->X,pos->Y,pos->Z);
	}
	// --------------

	GTA::Quaternion^ Vehicle::Quaternion::get()
	{
		float w,x,y,z;
		pin_ptr<float> pW = &w;
		pin_ptr<float> pX = &x;
		pin_ptr<float> pY = &y;
		pin_ptr<float> pZ = &z;
		Scripting::GetVehicleQuaternion(Base,pW,pX,pY,pZ);
		GTA::Quaternion^ quat = gcnew GTA::Quaternion(w,x,y,z);
		return quat;
	}
	void Vehicle::Quaternion::set(GTA::Quaternion^ pos)
	{
		Scripting::SetVehicleQuaternion(Base,pos->W,pos->X,pos->Y,pos->Z);
	}

	f32 Vehicle::Heading::get()
	{
		float heading;
		pin_ptr<float> pheading = &heading;
		Scripting::GetCarHeading(Base,pheading);
		return heading;
	}
	void Vehicle::Heading::set(f32 heading)
	{
		Scripting::SetCarHeading(Base,heading);
	}

	u32 Vehicle::Health::get()
	{
		u32 health;
		pin_ptr<u32> phealth = &health;
		Scripting::GetCarHealth(Base,phealth);
		return health;
	}
	void Vehicle::Health::set(u32 health)
	{
		Scripting::SetCarHealth(Base,health);
	}

	GTA::eModel Vehicle::Model::get()
	{
		GTA::eModel model;
		pin_ptr<GTA::eModel> pmodel = &model;
		Scripting::GetCarModel(Base,(Scripting::eModel*)pmodel);
		return model;
	}
#pragma endregion Coordinates, Quaternion, Heading, Health, Model

#pragma region Methods
//
#pragma endregion 

};